<template>
    <div style="min-height: 100vh;background:#f5f5f5;"> 
        <van-address-list
        v-model="chosenAddressId"
        :list="list"
        @add="onAdd"
        @edit="onEdit"
        @select="onselect"/>
        <div v-if="data.list.length==0">
            <div class="noAddress">
                <img src="@/assets/img/address1.png" alt="">
                <p>你还没有添加收货地址哦~</p>
            </div>
        </div>
    </div> 
</template>

<script>

    import request from "@/request/index.js"
    export default {
        name: "myAddress",
        components: {
            
        },
        data() {
            return {
                data:{},
                chosenAddressId: '1',
                list: [],
            }
        },
        watch:{
            
        },
        methods:{
            onAdd() {
                this.$router.push({
                    path: '/addAddress'
                });
            },

            onEdit(item, index) {
                this.$router.push({
                    path: '/editAddress?addressId='+item.id+'&name='+item.name+'&tel='+item.tel+'&area='+item.area+'&address='+item.smallAddress+'&is_default='+item.is_default+'&first_id='+item.first_id+'&second_id='+item.second_id+'&third_id='+item.third_id
                });
            },
            onselect(item,index){
                request.setDefaultAddress(this,item.id,item)
            }
        },
        mounted() {
            request.addressList(this);
        },
    }
</script>

<style scoped lang="scss">
    .myBalance{
        text-align: center;
        color: #ffffff;
        font-size: 13px;
        padding-top: 45px;
        p{
            
            font-size: 20px;
        }
    }
    .fanli{
        display: flex;
        justify-content: space-between;
        padding: 14px 0;
        >div{
            width:50%;
            text-align: center;
            font-size: 13px;
            color: #666666;
            font-size: 13px;

        }
        .allBlance,.monthBlance{
            color:#333333;
            font-size: 15px;
        }
    }
    .noAddress{
        text-align:center;
        padding-top: 120px;
        color: #333333;
        font-size: 14px;
        img{
            width: 158px;
            margin-bottom: 20px; 
        }
    }

</style>
